﻿<UserControl x:Class="XSemmel.XPath.XPathQueries"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:AvalonEdit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="500">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" MinHeight="125px" />
            <RowDefinition Height="4"/>
            <RowDefinition Height="2*" MinHeight="100px"/>
        </Grid.RowDefinitions>
                
        <DockPanel Grid.Row="0">
            <TextBlock DockPanel.Dock="Top">XPath:</TextBlock>
            <WrapPanel Orientation="Horizontal" HorizontalAlignment="Right" DockPanel.Dock="Bottom" >
                <Button Width="50" Margin="5" ToolTip="Executes a XPath in multiple files" Click="btnBulkXPath_OnClick">Bulk...</Button>
                <Button Width="90" Margin="5" Click="btnCopy_Click">Copy XPath</Button>
                <Button x:Name="_btnExecute" x:FieldModifier="private" Width="110" Margin="5" Click="btnExecute_Click" IsDefault="True">Execute</Button>
            </WrapPanel>
            <RadioButton DockPanel.Dock="Bottom" Name="_chkUseNamespaces" GroupName="x" IsChecked="True"
                         x:FieldModifier="private" Checked="_chkUseNamespaces_OnChecked">
                <RadioButton.Content>
                    <TextBlock Text="Extract Namespaces from XML document" TextWrapping="Wrap"/>
                </RadioButton.Content>
            </RadioButton>
            <RadioButton DockPanel.Dock="Bottom" Name="_chkUseUserdefinedFunctions" GroupName="x" IsChecked="False"
                         x:FieldModifier="private" Checked="_chkUseNamespaces_OnChecked">
                <RadioButton.Content>
                    <TextBlock Text="Use user-defined XPath functions (from XPathFunctions.cs file)" TextWrapping="Wrap"/>
                </RadioButton.Content>
            </RadioButton>
            <CheckBox DockPanel.Dock="Bottom" Name="_chkWhileTyping" IsChecked="True" x:FieldModifier="private">Check XPath while typing</CheckBox>
            <Border BorderThickness="1" BorderBrush="Silver">
                <AvalonEdit:TextEditor 
                        x:Name="_edtXPath" 
                        x:FieldModifier="private"
                        FontSize="10pt" 
                        TextChanged="edtXPath_TextChanged" 
                        FontFamily="Consolas" 
                        PreviewKeyDown="edtXPath_KeyDown">
                    <AvalonEdit:TextEditor.Template>
                        <ControlTemplate>
                            <ScrollViewer
                                Focusable="False"
                                CanContentScroll="True"
                                VerticalScrollBarVisibility="Auto"
                                HorizontalScrollBarVisibility="Auto"
                                Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TextArea}"
                                VerticalContentAlignment="Top"
                                HorizontalContentAlignment="Left"
                                Background="{TemplateBinding Background}"
                                Padding="{TemplateBinding Padding}"
                            />
                        </ControlTemplate>
                    </AvalonEdit:TextEditor.Template>
                    <AvalonEdit:TextEditor.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Copy" Click="btnCopy_Click"/>
                            <MenuItem Header="Paste" Click="mnuPaste_Click"/>
                            <MenuItem Header="Delete" Click="mnuDelete_Click"/>
                            <Separator/>
                            <MenuItem Header="Load from file..." Click="mnuLoadFromFile_Click"/>
                        </ContextMenu>
                    </AvalonEdit:TextEditor.ContextMenu>
                </AvalonEdit:TextEditor>
            </Border>
        </DockPanel>
        <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
        <TabControl TabStripPlacement="Left" Grid.Row="2">
            <TabControl.Resources>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="Padding" Value="4" />
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <ContentPresenter Content="{TemplateBinding Content}">
                                    <ContentPresenter.LayoutTransform>
                                        <RotateTransform Angle="-90" />
                                    </ContentPresenter.LayoutTransform>
                                </ContentPresenter>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.Resources>

            <TabItem Header="Tree">
                <TreeView Name="_treeResult" x:FieldModifier="private" SelectedItemChanged="treeResult_SelectedItemChanged"/>
            </TabItem>
            <TabItem Header="Fragment">
                <AvalonEdit:TextEditor x:Name="_editorUserControl1" x:FieldModifier="private" IsReadOnly="True" FontFamily="Consolas"
                                        FontSize="10pt" SyntaxHighlighting="XML" ShowLineNumbers="true" />
            </TabItem>
        </TabControl>
    </Grid>
            
</UserControl>
